|
|
|
|
|
|
|
Now, add some code to the project that will tell you when an event occurs. First, you need to get a message box to pop up each time you reposition the record pointer using the arrow buttons on the data control. To do this, place the following code in the Data1_Reposition event: |
|
|
|
|
|
|
|
|
Private Sub Data1_Reposition()
MsgBox "Repositioning the pointer..."
End Sub |
|
|
|
|
|
|
|
|
Next, to get a message box to pop up each time you leave a record using the data control's arrow buttons, place the following code in the Data1_Validate event: |
|
|
|
|
|
|
|
|
Private Sub Data1_Validate(Action As Integer, Save As Integer)
MsgBox "Validating Data..."
End Sub |
|
|
|
|
|
|
|
|
Now save and run the project. You'll notice that the message from the Reposition event is the first thing you see after the program begins. This is because the pointer is positioned on the first record in the Dynaset when the Dynaset is first created. (See Figure 4.5.) |
|
|
|
|
|
|
|
|
Figure 4.5.
The Reposition event at the start
of the program. |
|
|
|
|
|
|
|
|
After you click the OK button in the message box, you'll see the Visual Basic form with the data control. Click one of the arrow buttons. You'll see that the message from the Validate event pops up. This message is sent before Visual Basic leaves the current record. (See Figure 4.6.) |
|
|
|
|
|
|
|
|
Figure 4.6.
The Validate event message. |
|
|
|
|
|
|
|
|
After you click the OK button in the message box, you'll see the message from the Reposition event again. This is the event message sent when Visual Basic reads the next record. |
|
|
|
|
|
|
|
|
You might have noticed that the header for the Validate event contains two parameters: Action and Save. These two parameters can be used to learn more about what action is currently being attempted on the data control and can give you control over whether the user should be allowed to save the new data to the Dynaset. These parameters are set by Visual Basic while the program is running. You can read the values in these parameters at any time |
|
|
|
|
|